<?php if ($pagination->mustPaginate()): ?>
    <?php $url .= strpos($url, '?') ? '&amp;' : '?'; ?>
    <nav class="pagination">
        <ul class="pagination__container">
            <?php if ($pagination->isCurrentFirstPage()): ?>
                <li class="pagination__item pagination__item--prev pagination__item--disabled">
                    <?= icon('angle-down', 'rotate90') ?>
                </li>
            <?php else: ?>
                <li class="pagination__item pagination__item--prev">
                    <a title="<?= _('Previous page') ?>" class="pagination__link" href="<?= $url . 'page=' . $pagination->previousPageNumber() ?>">
                        <?= icon('angle-down', 'rotate90') ?>
                        <span class="sr-only">
                            <?= _('Previous page') ?>
                        </span>
                    </a>
                </li>
            <?php endif; ?>

            <?php foreach ($pagination->pages() as $page): ?>
                <?php if ($page['type'] === 'number'): ?>
                    <li class="pagination__item pagination__item--number <?= $pagination->isPageCurrent($page['number']) ? 'pagination__item--current' : '' ?>">
                        <a
                            class="pagination__link"
                            href="<?= $url . 'page=' . $page['number'] ?>"
                            <?= $pagination->isPageCurrent($page['number']) ? 'aria-current="page"' : '' ?>
                        >
                            <?= $page['number'] ?>
                        </a>
                    </li>
                <?php else: ?>
                    <li class="pagination__item pagination__item--ellipsis">
                        …
                    </li>
                <?php endif; ?>
            <?php endforeach; ?>

            <?php if ($pagination->isCurrentLastPage()): ?>
                <li class="pagination__item pagination__item--next pagination__item--disabled">
                    <?= icon('angle-down', 'rotate270') ?>
                </li>
            <?php else: ?>
                <li class="pagination__item pagination__item--next">
                    <a title="<?= _('Next page') ?>" class="pagination__link" href="<?= $url . 'page=' . $pagination->nextPageNumber() ?>">
                        <?= icon('angle-down', 'rotate270') ?>
                        <span class="sr-only">
                            <?= _('Next page') ?>
                        </span>
                    </a>
                </li>
            <?php endif; ?>
        </ul>
    </nav>
<?php endif; ?>
